$(document).ready(function() {
	var $_ipt_slt = $(".ipt_select");
    $_ipt_slt.focus(function() {
        var $t = $(this);
        $(".pwp_select").hide();
        $(".j_select_li").removeClass("zindex");
        $t.parent().find(".pwp_select").show();
        $t.parent().addClass("zindex");
    });
    $(".j_select_li li").click(function(evt) {
        evt.stopPropagation();
        var $t = $(this);
        $p = $t.closest(".j_select_li"),
            $input = $p.find(".ipt_select");
        if ($t.index() != 0) {
            $input.val($t.html());
        	$("#hiddenques1").val($t.attr("data-value"));
            $input.trigger("validate");
        } else {
            return false;
        }
        //$p.find(".pwp_select").hide();
    });


    $_ipt_slt.blur(function(evt) {
        evt.stopPropagation();
        var $t = $(this);
        setTimeout(function() {
            $t.parent().find(".pwp_select").hide();
        }, 250);
    });
    
	var remoteTrans = new Helper.RemoteTrans({
		url:Helper.basePath+"/memberCenter/upSetQuestion.htm",
		onError:function(json){
			Helper.message(json.message);
		},
		onSuccess:function(json) {
			if(json.code=="0000"){
				Helper.message("密保问题修改成功");
				location.href=Helper.basePath+"/memberCenter/toPersonSet.htm";
			}else{
				Helper.message("系统繁忙，请稍后重试");
			}
		}
	});
	//修改密保问题
	$("#setQuestion").click(function(){
		var ques1=$("#ques1").val();
		var oldQuestion=$("#oldQuestionName").val();
		var answerold=$("#answerold").val();
		var questionTypenew=$("#hiddenques1").val();
		var answernew=$("#answer1").val();
		if(ques1=="0"){
			Helper.message("请选择密保问题");
			return;
		}
		if(answerold==""){
			Helper.message("旧问题答案不可为空");
			return;
		}
		if(answernew==""){
			Helper.message("密保答案不可为空");
			return;
		}
		if(answernew.length < 0 || answernew.length > 21){
			Helper.message("密保答案长度非法");
			return;
		}
		
		remoteTrans.params = {questionTypeold:oldQuestion,answerold:answerold,questionTypenew:questionTypenew,answernew:answernew};
		remoteTrans.send();
	});
	
	
	
});